package com.kuangshen.exceptiondemo;

public class Test2 {
    public static void main(String[] args) {
        try {
//            new Test2().test(1, 0);
            new Test2().test1();
        } catch (MyException e) {
            e.printStackTrace();
            System.out.println(e.getMessage());
        }
    }

    public void test(int a, int b) throws ArithmeticException{
        if(b==0){
            throw new ArithmeticException("fsdfs"); // 主动的抛出异常, 一般在方法中使用
        }
    }


    public void test1() throws MyException{
        throw new MyException("fdsfsdf");
    }
}
